{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello!\n"
     ]
    }
   ],
   "source": [
    "# 定义函数\n",
    "def sayHello():\n",
    "    print('hello!')\n",
    "# 调用函数|执行函数\n",
    "sayHello()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello!小兔子\n"
     ]
    }
   ],
   "source": [
    "def sayHello(name):\n",
    "    print('hello!'+name)\n",
    "sayHello('小兔子')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1>>> 15990912\n",
      "2>>> 15990912\n",
      "3>>> 15991056\n"
     ]
    }
   ],
   "source": [
    "def abc(a):\n",
    "    print('2>>>',id(a))   # 指向的是同一个对象\n",
    "    a=10\n",
    "    print('3>>>',id(a))   # 一个新对象\n",
    " \n",
    "a=1\n",
    "print('1>>>',id(a))\n",
    "abc(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def abc(a):\n",
    "    print('2>>>',id(a))   # 指向的是同一个对象\n",
    "    a=10\n",
    "    print('3>>>',id(a))   # 一个新对象\n",
    " \n",
    "a=1\n",
    "print('1>>>',id(a))\n",
    "for item in range(0,100):\n",
    "    abc(a)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "张新民女士\n"
     ]
    }
   ],
   "source": [
    "def print_name(name,sex):\n",
    "    if sex=='男':\n",
    "\t    print(name+'先生')\n",
    "    elif sex=='女':\n",
    "\t    print(name+'女士')\n",
    "print_name('张新民','女')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
